<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta content="telephone=no" name="format-detection" />
    <!-- 留作将来统一添加 -->
    <TEMPLATE>${TEMPLATE}</TEMPLATE>
    <title>模板html</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/index.css">
    <link rel="stylesheet" type="text/css" href="../../css/data-flex.min.css">
    <style type="text/css">
        .header-box {
            height: 44px;
            border-bottom: 1px solid #e4e4e4;
        }
        .item {
            line-height: 44px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="vueApp" v-cloak>
        <div class="header-box" data-flex="box:mean cross:center">
            <div v-for="item,index in listData" class="item" @click="handleItem(item)">
                条目{{index}}
            </div>
        </div>
        <div id="barChart"></div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/service/service-tool.js"></script>
<script type="text/javascript" src="../../script/service/service-app.js"></script>
<script type="text/javascript" src="../../script/service/service-user.js"></script>
<script type="text/javascript" src="../../script/service/service-logic.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/echarts.js"></script>
<script type="text/javascript">
    // html 的引号一律为双引号(""),js 为单引号('')
    var USER, $S, vm;
    apiready = function(){
        $S = SERVICE();
        USER = USER();
        console.log(JSON.stringify(api.pageParam) + '=====pageParam');
        
        fnInit();
    };
    
    // 初始化
    function fnInit() {
        vm = new Vue({
            el: '.vueApp',
            data: {
                info: null,
                listData: [{},{}],
                pageNo: 1,
                pageSize: 10
            }
        });
        // getPageData();
        $('#barChart').css('height', window.screen.availHeight - 44);
        drawChart();
    }

    function drawChart() {
        var myChart = echarts.init(document.getElementById('barChart'));
        var option = {
                legend: {
                    data: ['2011年', '2012年']
                },
                grid: {
                    left: '10',
                    right: '30',
                    bottom: '10',
                    containLabel: true
                },
                xAxis: {
                    position: 'top',
                    type: 'value',
                    boundaryGap: [0, 0.01]
                },
                yAxis: {
                    type: 'category',
                    data: ['巴西', '印尼', '美国', '印度', '中国', '世界人口(万)', 'demo']
                },
                series: [
                    {
                        name: '2011年',
                        type: 'bar',
                        data: [18203, 23489, 29034, 104970, 131744, 630230, 12122]
                    },
                    {
                        name: '2012年',
                        type: 'bar',
                        data: [19325, 23438, 31000, 121594, 134141, 681807, 12121]
                    },
                    {
                        name: '2013年',
                        type: 'bar',
                        data: [59325, 13438, 61000, 821594, 434141, 181807, 82121]
                    }
                ]
            };
        myChart.setOption(option);
        myChart.on('click', 'series.bar', function (e) {
            var index = e.dataIndex, name = e.name;
            debugger
            // 跳转相应页面
        });
    }

    // 获取页面数据
    function getPageData() {
        var url = '';
        var params = {};
        var callback = function(data) {
            var listData = data.listData;
            for(var i = 0; i < listData.length; i ++) {
                var item = listData[i];

            }
            vm.listData = vm.listData.concat(data.listData);
            // status 为200时,只返回data
        };
        POST(url, params, callback);
    }

    // 点击item
    function handleItem(item) {

    }
</script>
</html>